import {observable, action, toJS} from 'mobx';
import {WeaTableNew, WeaForm} from 'comsMobx'
const {TableStore} = WeaTableNew;
import Apis from '../apis/Api'

class TabListStore {
  @observable tableStore = new TableStore();
  @observable title = '加载中...';
  @observable conditions = [];
  @observable form = new WeaForm(); // 表单
  @observable showSearchAd = false;
  showTypeId = '';
  
  @action
  search = () => {
  
    let resultParams = this.form.getFormParams();
    resultParams = { ...resultParams, showtypeid: this.showTypeId};
    Apis.listSearchKey(resultParams).then((result) => {
      this.tableStore.getDatas(result.dataKey, 1);
    });
  }
  getTitle = (showTypeId) => {
    this.showTypeId = showTypeId;
    Apis.listSearchTitle({showtypeid: showTypeId}).then((result) => {
      this.title = result.title;
    });
  }
  getCondition = () => {
    Apis.listSearchParam({showtypeid: this.showTypeId}).then((result) => {
      this.conditions = [{items: result}];
      this.form.initFormFields(this.conditions)
    });
  }
  setShowSearchAd = (bool) => {
    this.showSearchAd = bool;
  }
  
  
}
export default TabListStore;